<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base = "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
    <div class="layui-form-item">
        <label class="layui-form-label">设备名称</label>
        <div class="layui-input-block">
            <input type="text" id="name" name="name" autocomplete="off" placeholder="请输入设备名称"
                   class="layui-input">
            <button type="button" class="layui-btn" id="name-url">
                <i class="layui-icon">&#xe67c;</i>设备名称图片上传
            </button>
            <img id="name-url-img" src="">
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">设备用途</label>
        <div class="layui-input-block">
            <input type="text" id="purpose" name="purpose" autocomplete="off" placeholder="请输入设备用途"
                   class="layui-input">
            <button type="button" class="layui-btn" id="purpose-url">
                <i class="layui-icon">&#xe62c;</i>设备用途 图片上传
            </button>
            <img id="purpose-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">设备检定情况及相关要求</label>
        <div class="layui-input-block">
            <input type="text" id="requirement" name="requirement" autocomplete="off" placeholder="请输入设备检定情况及相关要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="requirement-url">
                <i class="layui-icon">&#xe62c;</i>设备检定情况及相关要求 图片上传
            </button>
            <img id="requirement-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">功能要求（协议书）</label>
        <div class="layui-input-block">
            <input type="text" id="function" name="function" autocomplete="off" placeholder="请输入功能要求（协议书）"
                   class="layui-input">
            <button type="button" class="layui-btn" id="function-url">
                <i class="layui-icon">&#xe62c;</i>功能要求（协议书） 图片上传
            </button>
            <img id="function-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性能指标要求（协议书）</label>
        <div class="layui-input-block">
            <input type="text" id="performance" name="performance" autocomplete="off" placeholder="请输入性能指标要求（协议书）"
                   class="layui-input">
            <button type="button" class="layui-btn" id="performance-url">
                <i class="layui-icon">&#xe62c;</i>性能指标要求（协议书） 图片上传
            </button>
            <img id="performance-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">接口要求</label>
        <div class="layui-input-block">
            <input type="text" id="Interface" name="Interface" autocomplete="off" placeholder="请输入接口要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="Interface-url">
                <i class="layui-icon">&#xe62c;</i>接口要求 图片上传
            </button>
            <img id="Interface-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">重量要求</label>
        <div class="layui-input-block">
            <input type="text" id="weight" name="weight" autocomplete="off" placeholder="请输入重量要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="weight-url">
                <i class="layui-icon">&#xe62c;</i>重量要求 图片上传
            </button>
            <img id="weight-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">尺寸要求</label>
        <div class="layui-input-block">
            <input type="text" id="size" name="size" autocomplete="off" placeholder="请输入尺寸要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="size-url">
                <i class="layui-icon">&#xe62c;</i>尺寸要求 图片上传
            </button>
            <img id="size-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电源特性要求</label>
        <div class="layui-input-block">
            <input type="text" id="powerSupply" name="powerSupply" autocomplete="off" placeholder="请输入电源特性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="powerSupply-url">
                <i class="layui-icon">&#xe62c;</i>电源特性要求 图片上传
            </button>
            <img id="powerSupply-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">寿命</label>
        <div class="layui-input-block">
            <input type="text" id="life" name="life" autocomplete="off" placeholder="请输入寿命"
                   class="layui-input">
            <button type="button" class="layui-btn" id="life-url">
                <i class="layui-icon">&#xe62c;</i>寿命 图片上传
            </button>
            <img id="life-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">可靠性要求</label>
        <div class="layui-input-block">
            <input type="text" id="reliability" name="reliability" autocomplete="off" placeholder="请输入可靠性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="reliability-url">
                <i class="layui-icon">&#xe62c;</i>可靠性要求 图片上传
            </button>
            <img id="reliability-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">维修性要求</label>
        <div class="layui-input-block">
            <input type="text" id="maintainability" name="maintainability" autocomplete="off" placeholder="请输入维修性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="maintainability-url">
                <i class="layui-icon">&#xe62c;</i>维修性要求 图片上传
            </button>
            <img id="maintainability-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">测试性要求</label>
        <div class="layui-input-block">
            <input type="text" id="testability" name="testability" autocomplete="off" placeholder="请输入测试性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="testability-url">
                <i class="layui-icon">&#xe62c;</i>测试性要求 图片上传
            </button>
            <img id="testability-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">安全性要求</label>
        <div class="layui-input-block">
            <input type="text" id="security" name="security" autocomplete="off" placeholder="请输入安全性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="security-url">
                <i class="layui-icon">&#xe62c;</i>安全性要求 图片上传
            </button>
            <img id="security-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">保障性要求</label>
        <div class="layui-input-block">
            <input type="text" id="supportability" name="supportability" autocomplete="off" placeholder="请输入保障性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="supportability-url">
                <i class="layui-icon">&#xe62c;</i>保障性要求 图片上传
            </button>
            <img id="supportability-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">环境适应性要求</label>
        <div class="layui-input-block">
            <input type="text" id="environment" name="environment" autocomplete="off" placeholder="请输入环境适应性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="environment-url">
                <i class="layui-icon">&#xe62c;</i>环境适应性要求 图片上传
            </button>
            <img id="environment-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电磁兼容性要求</label>
        <div class="layui-input-block">
            <input type="text" id="electromagnetism" name="electromagnetism" autocomplete="off" placeholder="请输入电磁兼容性要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="electromagnetism-url">
                <i class="layui-icon">&#xe62c;</i>电磁兼容性要求 图片上传
            </button>
            <img id="electromagnetism-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">计量保障要求</label>
        <div class="layui-input-block">
            <input type="text" id="metering" name="metering" autocomplete="off" placeholder="请输入计量保障要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="metering-url">
                <i class="layui-icon">&#xe62c;</i>计量保障要求 图片上传
            </button>
            <img id="metering-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">包装运输要求</label>
        <div class="layui-input-block">
            <input type="text" id="packingTransport" name="packingTransport" autocomplete="off" placeholder="请输入包装运输要求"
                   class="layui-input">
            <button type="button" class="layui-btn" id="packingTransport-url">
                <i class="layui-icon">&#xe62c;</i>包装运输要求 图片上传
            </button>
            <img id="packingTransport-url-img" src="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">技术资料</label>
        <div class="layui-input-block">
            <input type="text" id="technology" name="technology" autocomplete="off" placeholder="请输入技术资料"
                   class="layui-input">
        </div>
    </div>


    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer', 'upload'], function () {
        var form = layui.form
            , layer = layui.layer, upload = layui.upload;


        var name_url = "==",
            purpose_url = "==",
            requirement_url = "==",
            function_url = "==",
            performance_url = "==",
            Interface_url = "==",
            weight_url = "==",
            size_url = "==",
            powerSupply_url = "==",
            life_url = "==",
            reliability_url = "==",
            maintainability_url = "==",
            testability_url = "==",
            security_url = "==",
            supportability_url = "==",
            environment_url = "==",
            electromagnetism_url = "==", metering_url = "==", packingTransport_url = "==";

        var uploadInst = upload.render({
            elem: '#name-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#name-url-img").attr('src', res.data);
                name_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });

        upload.render({
            elem: '#purpose-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#purpose-url-img").attr('src', res.data);
                purpose_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#requirement-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#requirement-url-img").attr('src', res.data);
                requirement_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#function-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#function-url-img").attr('src', res.data);
                function_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#performance-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#performance-url-img").attr('src', res.data);
                performance_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#Interface-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#Interface-url-img").attr('src', res.data);
                Interface_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#weight-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#weight-url-img").attr('src', res.data);
                weight_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#size-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#size-url-img").attr('src', res.data);
                size_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#powerSupply-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#powerSupply-url-img").attr('src', res.data);
                powerSupply_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#life-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#life-url-img").attr('src', res.data);
                life_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#reliability-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#reliability-url-img").attr('src', res.data);
                reliability_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#maintainability-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#maintainability-url-img").attr('src', res.data);
                maintainability_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#testability-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#testability-url-img").attr('src', res.data);
                testability_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#security-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#security-url-img").attr('src', res.data);
                security_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#supportability-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#supportability-url-img").attr('src', res.data);
                supportability_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#environment-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#environment-url-img").attr('src', res.data);
                environment_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#electromagnetism-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#electromagnetism-url-img").attr('src', res.data);
                electromagnetism_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#metering-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#metering-url-img").attr('src', res.data);
                metering_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });
        upload.render({
            elem: '#packingTransport-url' //绑定元素
            , url: base + '/aircraftanalysis/setImg/' //上传接口
            , done: function (res) {
                //上传完毕回调
                $("#packingTransport-url-img").attr('src', res.data);
                packingTransport_url += res.data;
            }
            , error: function () {
                //请求异常回调
                alert("上传失败" + res.message);
            }
        });

        $("#submit").on("click", function () {
            if (check() === false) {
                return;
            }

            var formDate = {
                name: $("#name").val() + name_url,
                purpose: $("#purpose").val() + purpose_url,
                requirement: $("#requirement").val()+requirement_url,
                function: $("#function").val()+function_url,
                performance: $("#performance").val()+performance_url,
                Interface: $("#Interface").val()+Interface_url,
                weight: $("#weight").val()+weight_url,
                size: $("#size").val()+size_url,
                powerSupply: $("#powerSupply").val()+powerSupply_url,
                life: $("#life").val()+life_url,
                reliability: $("#reliability").val()+requirement_url,
                maintainability: $("#maintainability").val()+maintainability_url,
                testability: $("#testability").val()+testability_url,
                security: $("#security").val()+security_url,
                supportability: $("#supportability").val()+supportability_url,
                environment: $("#environment").val()+environment_url,
                electromagnetism: $("#electromagnetism").val()+electromagnetism_url,
                metering: $("#metering").val()+metering_url,
                packingTransport: $("#packingTransport").val()+packingTransport_url,
                technology: $("#technology").val()
            }
            console.log("=================")
            console.log($("#name").val() + name_url)
            console.log(formDate.name)


            $.ajax({
                type: "POST",
                url: base + "/aircraftanalysis/engine/admin/addEngine",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href = base + "/aircraftanalysis/engine/admin/main.html"
                    } else {

                    }
                }
            });
        })


        function check() {
            // if($("#name").val().length<1){
            //     layer.msg("请输入设备名称");
            //     return false;
            // }
            // if($("#purpose").val().length<1){
            //     layer.msg("请输入设备用途");
            //     return false;
            // }
            // if($("#requirement").val().length<1){
            //     layer.msg("请输入设备检定情况及相关要求");
            //     return false;
            // }
            // if($("#function").val().length<1){
            //     layer.msg("请输入功能要求（协议书）");
            //     return false;
            // }
            // if($("#performance").val().length<1){
            //     layer.msg("请输入性能指标要求（协议书）");
            //     return false;
            // }
            // if($("#Interface").val().length<1){
            //     layer.msg("请输入接口要求");
            //     return false;
            // }
            // if($("#weight").val().length<1){
            //     layer.msg("请输入重量要求");
            //     return false;
            // }
            // if($("#size").val().length<1){
            //     layer.msg("请输入尺寸要求");
            //     return false;
            // }
            // if($("#powerSupply").val().length<1){
            //     layer.msg("请输入电源特性要求");
            //     return false;
            // }
            // if($("#life").val().length<1){
            //     layer.msg("请输入寿命");
            //     return false;
            // }
            // if($("#reliability").val().length<1){
            //     layer.msg("请输入可靠性要求");
            //     return false;
            // }
            // if($("#maintainability").val().length<1){
            //     layer.msg("请输入维修性要求");
            //     return false;
            // }
            // if($("#testability").val().length<1){
            //     layer.msg("请输入测试性要求");
            //     return false;
            // }
            // if($("#security").val().length<1){
            //     layer.msg("请输入安全性要求");
            //     return false;
            // }
            // if($("#supportability").val().length<1){
            //     layer.msg("请输入保障性要求");
            //     return false;
            // }
            // if($("#environment").val().length<1){
            //     layer.msg("请输入环境适应性要求");
            //     return false;
            // }
            // if($("#electromagnetism").val().length<1){
            //     layer.msg("请输入电磁兼容性要求");
            //     return false;
            // }
            // if($("#metering").val().length<1){
            //     layer.msg("请输入计量保障要求");
            //     return false;
            // }
            // if($("#packingTransport").val().length<1){
            //     layer.msg("请输入包装运输要求");
            //     return false;
            // }
            // if($("#technology").val().length<1){
            //     layer.msg("请输入技术资料");
            //     return false;
            // }
        }
    });

</script>
</body>
</html>